import axios from '@/utils/request'

// 登陆
export const login = (val) => {
  return axios({ method: 'post', url: '/v1_0/authorizations', data: val })
}

// 拉黑用户
export const defriendUserFn = (target) => {
  return axios({
    method: 'post',
    url: '/v1_0/user/blacklists',
    data: { target }
  })
}

// 取消拉黑用户
export const removeDefriend = (id) => {
  return axios({
    method: 'delete',
    url: `/v1_0/user/blacklists/${id}`
  })
}

// 关注用户
export const followUser = (target) => {
  return axios({
    method: 'post',
    url: '/v1_0/user/followings',
    data: { target }
  })
}

// 取消关注用户
export const unFollowUser = (target) => {
  return axios({
    method: 'delete',
    url: `/v1_0/user/followings/${target}`
  })
}

// 获取指定用户信息
export const getTargetUser = (target) => {
  return axios({
    method: 'get',
    url: `/v1_0/users/${target}`,
    params: {
      target
    }
  })
}

// 刷新用户token
export const getNewToken = (freshToken) => {
  return axios({
    method: 'put',
    url: '/v1_0/authorizations',
    headers: {
      Authorization: 'Bearer' + ' ' + freshToken
    }
  })
}

// 获取用户自己信息
export const getUserInfo = () => {
  return axios({
    method: 'get',
    url: '/v1_0/user'
  })
}

// 获取用户个人资料
export const getUserProfile = () => {
  return axios({
    method: 'get',
    url: '/v1_0/user/profile'
  })
}

// 编辑用户个人资料
export const editUserProfile = (data) => {
  return axios({
    method: 'patch',
    url: '/v1_0/user/profile',
    data
  })
}

// 编辑用户照片资料
export const editPhoto = (data) => {
  return axios({
    method: 'patch',
    url: '/v1_0/user/photo',
    data
  })
}
